package com.demo.richText.pojo.vo;

import cn.hutool.core.codec.Base64;
import cn.hutool.http.HtmlUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.demo.richText.pojo.Article;
import com.demo.richText.pojo.ArticleFile;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description TODO
 * @Author 小乌龟
 * @Date 2022/9/5 9:51
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="展示文章", description="")
public class ReShowArticle {
    @ApiModelProperty("文章Id")
    private Long articleId;

    @ApiModelProperty("文章名称")
    private String articleName;

    @ApiModelProperty("文章作者")
    private String articleAuthor;


    @ApiModelProperty("文章内容")
    private String articleContent;

    @ApiModelProperty("更新时间")
    private LocalDateTime gmtUpdate;


    public static ReShowArticle toReShow(Article article){
        return new ReShowArticle()
                .setArticleId(article.getPkId())
                .setArticleName(article.getArticleName())
                .setArticleAuthor(article.getArticleAuthor())
                //入数据库转义安全字符 需要转义回来 html解码 base32解码 base64解码
//                .setArticleContent(HtmlUtil.unescape(article.getArticleContent()))
//                .setArticleContent(Base32.decodeStrHex(article.getArticleContent()))
                 .setArticleContent(Base64.decodeStr(article.getArticleContent()))
                .setGmtUpdate(article.getGmtUpdate());
    }
}
